package C_Paper;

import java.util.Arrays;
import java.util.Scanner;

public class C100_2 {
    //https://fcqian.blog.csdn.net/article/details/135085069?spm=1001.2014.3001.5502
    //螺旋数字矩阵
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] ar = new int[m][n % m == 0 ?n / m:n / m + 1];
        int j = 0;
        int k = 0;
        int q = 0;
        int li = ar[0].length - 1;
        int ll = m - 1;
        for (int i = 1; i <= n; i++) {
            if (ar[j][k] != 0) {
                q++;
                j++;
                k++;
            }
            ar[j][k] = i;
            if (j == q && k < li - q){
                k++;
                continue;
            }
            if (j < ll - q && k == li - q){
                j++;
                continue;
            }
            if (j == ll - q && k > q){
                k--;
                continue;
            }
            j--;
        }
        for (int i = 0; i < m; i++) {
            for (int l = 0; l < ar[0].length; l++) {
                System.out.print(ar[i][l] == 0 ? "* " : ar[i][l] + " ");
            }
            System.out.println();
        }
    }
}
